package com.xt;

import com.xt.bean.PlatformResult;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 全局异常处理器
 * Created by XT on 2018/3/5.
 */
@ControllerAdvice
public class GlobalDefaultExceptionHandler {

    /**
     * 处理 Exception 类型的异常
     * @param e
     * @return
     */
    @ExceptionHandler(Exception.class)
    @ResponseBody
    public PlatformResult defaultExceptionHandler(Exception e) {
        return PlatformResult.build(GlobalConstant.CODE_EXCEPTION,e.getMessage());
    }
}
